package com.zhou.function

import java.util.Date

/*
 * @Description: 偏应用函数
 * @Author: ZhOu 
 * @Date: 2018/6/12
 */
object PartiallyAppliedFunction {

  def log(date: Date, message: String): Unit = {
    println(date + "\t" + message)
  }

  def main(args: Array[String]): Unit = {
    val date = new Date()
    log(date, "msg1......")
    Thread.sleep(1000)
    log(date, "msg2.......")
    Thread.sleep(1000)
    log(date, "msg3.......")

    //绑定date参数，第二个参数使用下划线替代缺失参数
    val logWithDateBound = log(date, _: String)
    logWithDateBound("msg1......")
    Thread.sleep(1000)
    logWithDateBound("msg2.......")
    Thread.sleep(1000)
    logWithDateBound("msg3.......")

  }
}
